"""
文件读写缓冲
"""


#fw = open("file1.txt","w",buffering=1)

# 设置缓冲大小 10字节，必须以二进制打开才可以设置缓冲区大小
fw = open("file1.txt","wb",buffering=10)

while True:
    msg = input(">>")
    if not msg:
        break
    fw.write(msg.encode())
    #fw.flush() # 主动刷新 ctrl-s

fw.close()